<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>添加、编辑作品-后台管理-{$site.SITE_INFO.name}</title>
        <php>
            $addCss="";
            $addJs="";
            $currentNav ='作品管理 > 添加编辑作品';
        </php>
        <include file="Common:intoHead" />
        <link rel="stylesheet" type="text/css" href="__CSS__/webuploader.css">
        <script type="text/javascript" src="__JS__/webuploader.min.js"></script>
        <link rel="stylesheet" href="__PUBLIC__/Home/css/jquery.autocompleter.css">
        <link rel="stylesheet" href="__PUBLIC__/Js/jquery-ui-1.12/jquery-ui.css">
        <style>
            div.spot {
                float: left;
                margin: 0 20px 0 0;
                width: 220px;
                min-height: 160px;
                border: 2px dashed #ddd;
            }
            .droparea {
                position: relative;
                text-align: center;
            }
            .droparea .instructions {
                opacity: 0.8;
                background-color: #cccccc;
                height: 25px;
                z-index: 10;
                zoom: 1;
                background-position: initial initial;
                background-repeat: initial initial;
                cursor: pointer;
            }
            .droparea div, .droparea input {
                position: absolute;
                top: 0;
                width: 100%;
                height: 100%;
            }
            .droparea input {
                cursor: pointer;
                opacity: 0;
            }
            .droparea div, .droparea input {
                position: absolute;
                top: 0;
                width: 100%;
                height: 100%;
            }
            #uparea1,#uparea2,#uparea3,#uparea4{
                height: 170px;
                cursor: pointer;
            }
            .progress-bar{
                background:rgba(0,183,238,1);
                height: 20px;
                line-height: 20px;
            }
            #picker .item{
                border: 1px #aaa dashed;
                padding: 5px;
                margin-top: 8px;
            }
            #picker .state{
                display:inline-block;
                margin-right: 12px;
            }
            #picker .del_file{
                padding: 1px 4px;
            }
            .wrap tr{text-align:left}
            .autocompleter{width: 76px;}
			.autocompleter-list {
			    border: 1px solid rgba(82, 168, 236, 0.8);
				    box-shadow: 2px 2px 2px #F0F0F0 inset;
			    border-top: none;
			    background-color: #fff;
			}
			.autocompleter-item{padding-left: 5px;}
        </style>
    </head>
    <body>
        <div class="wrap">
            <include file="Common:head" />
            <div class="mainBody">
                <include file="Common:left" />
                <div id="Right">
                    <div class="Item hr">
                        <div class="current">添加编辑作品</div>
                    </div>
                    <form>
                        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table1">
                           <tr style="display: none">
                                <th>语言选择：</th>
                                <td>
                                    <select name="info[lang]">
                                        <option value="zh-cn" <if condition="$info['lang'] eq 'zh-cn'">selected</if> >简体中文</option>
                                        <option value="en-us" <if condition="$info['lang'] eq 'en-us'">selected</if> >English</option>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <th width="100">广告标题：</th>
                                <td><input id="title" type="text" class="input" size="60" name="info[title]" value="{$info.title}"/> <a href="javascript:void(0)" id="checkNewsTitle">检测是否重复</a></td>
                            </tr>

                            <tr>
                                <th width="100">发布状态：</th>
                                <td><label><input type="radio" name="info[status]" value="0" <if condition="$info.status eq 0"> checked="checked"</if> /> 作品审核状态</label> &nbsp; <label><input type="radio" name="info[status]" value="1" <if condition="($info.status eq 1) OR ($info.status eq null )"> checked="checked"</if> /> 作品已发布状态</label> </td>
                            </tr>
                            
                            <tr>
                                <th width="100">首页推荐类型：</th>
                                <td>
                                	<volist name='recommend_type' id='vo' key='k'>
	                                	<label><input type="radio" name="info[recommend_type]" value="{$k-1}" <if condition="$info.recommend_type eq $k-1"> checked="checked"</if> /> {$vo}</label>  &nbsp; 
                                	</volist>
                               	</td>
                            </tr>
                            <tr>
                                <th>需求：</th>
                                <td>
                                 <select name="info[t_xq]">
                                		{:get_cate_select(1,$info[t_xq])}
                                  </select> 
                                </td>
                            </tr>
                            <tr>
                                <th>行业：</th>
                                <td>
                                <select name="info[t_hy]">
                                	{:get_cate_select(2,$info[t_hy])}
                                </select>
                                </td>
                            </tr>
                            <tr>
                                <th>国家：</th>
                                <td>
                                	<input type="text" class="input" size="30" name='info[t_gj]' id='countryInput' value="{$info.t_gj}"  />
                                </td>
                            </tr>
                            <tr>
                                <th>时间：</th>
                                <td>
                                <select name="info[t_sj]">
                                	{:get_cate_select(4,$info[t_sj])}
                                </select>
                                <select name="info[t_sj_month]">
                                    <option>月份</option>
                                    <for start = "1" end="13">
                                        <option value="{$i}" <eq name="info[t_sj_month]" value="$i">selected</eq>>{$i}月</option>
                                    </for>
                                </select>
                                <select name="info[t_sj_day]">
                                    <option>日期</option>
                                    <for start = "1" end="32">
                                        <option value="{$i}" <eq name="info[t_sj_day]" value="$i">selected</eq>>{$i}日</option>
                                    </for>
                                </select>
                                </td>
                            </tr>

                            <tr>
                                <th>类型：</th>
                                <td>
                                <select name="info[t_lx]">
                                	{:get_cate_select(6,$info[t_lx])}
                                </select>
                                </td>
                            </tr>
                            <tr>
                                <th>奖项：</th>
                                <td>
                                <select class="" name="t_jx[]"  multiple="multiple" style='height:350px'>
                                	{:get_cate_select('484',$info[t_jx])}
                                </select>
                                <select class="" name="t_jx[]"  multiple="multiple" style='height:350px'>
                                	{:get_cate_select('485',$info[t_jx])}
                                </select>
                                </td>
                            </tr>
                            <tr>
                                <th>品牌名：</th>
                                <td><input type="text" class="input" size="60" name="info[brand]" value="{$info.brand}"/></td>
                            </tr>
                            <tr>
                                <th>品牌所属国：</th>
                                <td><input type="text" class="input" size="60" name="info[brand_country]" value="{$info.brand_country}"/></td>
                            </tr>
                            <tr>
                                <th>产品：</th>
                                <td><input type="text" class="input" size="60" name="info[product_type]" value="{$info.product_type}"/></td>
                            </tr>
                            <tr>
                                <th>企业主：</th>
                                <td><input type="text" class="input" size="60" name="info[man]" value="{$info.man}"/></td>
                            </tr>
                            <tr>
                                <th>代理公司：</th>
                                <td><input type="text" class="input" size="60" name="info[agency]" value="{$info.agency}"/></td>
                            </tr>
                            <tr>
                                <th>创意：</th>
                                <td><input type="text" class="input" size="60" name="info[new_idea]" value="{$info.new_idea}"/></td>
                            </tr>
                            <tr>
                                <th>文案：</th>
                                <td><input type="text" class="input" size="60" name="info[new_word]" value="{$info.new_word}"/></td>
                            </tr>
                            <tr>
                                <th>广告语：</th>
                                <td><input type="text" class="input" size="60" name="info[summary]" value="{$info.summary}"/></td>
                            </tr>
                            <tr>
                                <th>洞察相关度</th>
                                <td><div id="star" data-score="{$info.dcxgd}"></div></td>
                            </tr>
                            <tr>
                                <th>执行人员：</th>
                                <td><textarea class="input" style="height: 60px; width: 600px;" name="info[new_other]">{$info.new_other}</textarea></td>
                            </tr>
                            
                            <tr>
                                <th>导演：</th>
                                <td><input type="text" class="input" size="60" value='{$info.director}' name='info[director]' /></td>
                            </tr>
                            <tr>
                                <th>制作公司：</th>
                                <td><input type="text" class="input" size="60" value='{$info.production_company}' name='info[production_company]' /></td>
                            </tr>
                            
                            <!-- <tr>
                                <th>消费者洞察：</th>
                                <td><textarea class="input" style="height: 60px; width: 600px;" name="info[insight]">{$info.insight}</textarea></td>
                            </tr> -->

                            <tr>
                                <th>全部获奖：</th>
                                <td><textarea class="input" style="height: 60px; width: 600px;" name="info[awards]">{$info.awards}</textarea></td>
                            </tr>

                            <tr>
                                <th>创意洞察：</th>
                                <td><textarea class="" style="height: 80px; width: 80%;" name="info[content]">{$info['content']}</textarea></td>
                            </tr>
                            <tr>
                                <th>价值诉求：</th>
                                <td><textarea class="" style="height: 80px; width: 80%;" name="info[jzsq]">{$info['jzsq']}</textarea></td>
                            </tr>
                            <tr>
                                <th>描述：</th>
                                <td><textarea class="" style="height: 80px; width: 80%;" name="info[description]">{$info['description']}</textarea></td>
                            </tr>
                            <tr>
                                <th>作品图片：</th>
                                <td>
                                    <div class="droparea spot" id="image1" style="background-image: url('{$img_info[0]['savepath']}');background-size: 220px 160px;" >
                                        <div class="instructions" onclick="del_image('1')">删除</div>
                                        <div id="uparea1"></div>
                                        <input type="hidden" name="image_1[]" id="image_1" value="{$img_info[0]['savepath']}" />
                                    </div>
                                    <div class="droparea spot" id="image2" style="background-image: url('{$img_info[1]['savepath']}');background-size: 220px 160px;" >
                                        <div class="instructions" onclick="del_image('2')">删除</div>
                                        <div id="uparea2"></div>
                                        <input type="hidden" name="image_1[]" id="image_2" value="{$img_info[1]['savepath']}" />
                                    </div>
                                    <div class="droparea spot" id="image3" style="background-image: url('{$img_info[2]['savepath']}');background-size: 220px 160px;" >
                                        <div class="instructions" onclick="del_image('3')">删除</div>
                                        <div id="uparea3"></div>
                                        <input type="hidden" name="image_1[]" id="image_3" value="{$img_info[2]['savepath']}" />
                                    </div>
                                    <div class="droparea spot" id="image4" style="background-image: url('{$img_info[3]['savepath']}');background-size: 220px 160px;" >
                                        <div class="instructions" onclick="del_image('4')">删除</div>
                                        <div id="uparea4"></div>
                                        <input type="hidden" name="image_1[]" id="image_4" value="{$img_info[3]['savepath']}" />
                                    </div>
                                    <div class="droparea spot" id="image5" style="background-image: url('{$img_info[4]['savepath']}');background-size: 220px 160px;" >
                                        <div class="instructions" onclick="del_image('5')">删除</div>
                                        <div id="uparea5"></div>
                                        <input type="hidden" name="image_1[]" id="image_5" value="{$img_info[4]['savepath']}" />
                                    </div>
                                    <div class="droparea spot" id="image6" style="background-image: url('{$img_info[5]['savepath']}');background-size: 220px 160px;" >
                                        <div class="instructions" onclick="del_image('6')">删除</div>
                                        <div id="uparea6"></div>
                                        <input type="hidden" name="image_1[]" id="image_6" value="{$img_info[5]['savepath']}" />
                                    </div>
                                    <div class="droparea spot" id="image7" style="background-image: url('{$img_info[6]['savepath']}');background-size: 220px 160px;" >
                                        <div class="instructions" onclick="del_image('7')">删除</div>
                                        <div id="uparea7"></div>
                                        <input type="hidden" name="image_1[]" id="image_7" value="{$img_info[6]['savepath']}" />
                                    </div>
                                    <div class="droparea spot" id="image8" style="background-image: url('{$img_info[7]['savepath']}');background-size: 220px 160px;" >
                                        <div class="instructions" onclick="del_image('8')">删除</div>
                                        <div id="uparea8"></div>
                                        <input type="hidden" name="image_1[]" id="image_8" value="{$img_info[7]['savepath']}" />
                                    </div>
                                    <div class="droparea spot" id="image9" style="background-image: url('{$img_info[8]['savepath']}');background-size: 220px 160px;" >
                                        <div class="instructions" onclick="del_image('9')">删除</div>
                                        <div id="uparea9"></div>
                                        <input type="hidden" name="image_1[]" id="image_9" value="{$img_info[8]['savepath']}" />
                                    </div>点击空白处添加图片
                                </td>
                            </tr>
                            <tr>
                                <th>视频上传：</th>
                                <td>
                                    <div id="uploader" class="wu-example">
                                        用来存放文件信息
                                        <div id="thelist" class="uploader-list"></div>
                                        <div class="btns">
                                            <div id="picker">选择文件</div>
                                        </div>
                                        <volist name="videos" id="vo">
                                            <div id="WU_FILE_{$i}" class="item"><h4 class="info">{$vo}</h4><input class="del_file" type="button" value="删除"><input type="hidden" name="media[]" id="videoWU_FILE_{$i}" value="{$vo}"></div>
                                        </volist>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <th>关键词/标签：</th>
                                <td><input type="text" class="input" size="60" name="info[keywords]" value="{$info.keywords}"/>注意：请使用“,”分隔 例：超级碗,gaga,戛纳</td>
                            </tr>
                            <tr>
                            	<th>是否经典案例</th>
                            	<td>
                            		<label for="ra_1"><input type="radio" name='info[is_classics]' id='ra_1' value='1' {$info[is_classics] == 1 ? checked : ''} />是 </label>
                            		<label for="ra_2"><input type="radio" name='info[is_classics]' id='ra_2' value='0' {$info[is_classics] == 0 ? checked : ''} />否 </label>
                            	</td>
                            </tr>
                            
                        </table>
                        <php>if(empty($_GET['do'])){</php>
                        <input type="hidden" name="info[id]" value="{$info.id}" />
                        <php>}else{
                            $action_url=U('add');
                            }</php>
                    </form>
                    <div class="commonBtnArea" >
                        <button class="btn submit">提交</button>
                    </div>
                </div>
            </div>
        </div>
        <div class="clear"></div>
        <include file="Common:foot" />
        <script type="text/javascript" src="__PUBLIC__/Home/js/jquery.raty.min.js"></script>
        <script src="__PUBLIC__/Js/jquery-ui-1.12/jquery-ui.js" type="text/javascript"></script>
        <js href="--PUBLIC--/kindeditor/kindeditor-all-min.js,--PUBLIC--/kindeditor/lang/zh_CN.js"/>
        <script type="text/javascript">
      
        	//国家自动补全
	        $(function () {
	            $('#countryInput').autocomplete({ 
	            	source: JSON.parse('{$cate_country}'),
	            	focus: function(event, ui) {
	            	       $('#countryInput').attr('value',ui.item.label).val(ui.item.label)
		                   return false;
	                  },
	            	select: function (event, ui) {
	                    $('#countryInput').attr('value',ui.item.label).val(ui.item.label)
	                    return false;
	                }
	            	});
	            
	            
	            //星级评分插件
	            $('#star').raty({
	            	path: '__PUBLIC__/Home/js/raty/',
	            	number: 3,
	            	scoreName:"info[dcxgd]",
	            	  score: function() {
	            	    return $(this).attr('data-score');
	            	  }
	            }); 
	            
	            
	        });
        	
        	
            var uploader = WebUploader.create({

                auto:true,
                // swf文件路径
                swf:  '__JS__/Uploader.swf',

                // 文件接收服务端。
                server: '__JS__/fileupload.php',

                // 选择文件的按钮。可选。
                // 内部根据当前运行是创建，可能是input元素，也可能是flash.
                pick: '#picker',

                // 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
                resize: false,
                chunked:true,
                chunkSize: 2097152,
                threads:1
            });

            uploader.on( 'fileQueued', function( file ) {
                $("#picker").append( '<div id="' + file.id + '" class="item">' +
                    '<h4 class="info">' + file.name + '</h4>' + 
                    '<p class="state">等待上传...</p>' +
                '</div>' );
            });

            // 文件上传过程中创建进度条实时显示。
            uploader.on( 'uploadProgress', function( file, percentage ) {
                var $li = $( '#'+file.id ),
                    $percent = $li.find('.progress .progress-bar');

                // 避免重复创建
                if ( !$percent.length ) {
                    $percent = $('<div class="progress progress-striped active">' +
                      '<div class="progress-bar" role="progressbar" style="width: 0%">' +
                      '</div>' +
                    '</div>').appendTo( $li ).find('.progress-bar');
                }

                $li.find('p.state').text('上传中');

                $percent.css( 'width', percentage * 100 + '%' ).text(parseInt(percentage*100)+"%");
            });

            uploader.on( 'uploadSuccess', function( file ) {
                $( '#'+file.id ).find('p.state').text('已上传');
                $("#"+file.id).append('<input class="del_file" type="button" value="删除">');
                $("#"+file.id).append('<input type="hidden" name="media[]" id="video'+file.id+'" value="'+$( '#'+file.id ).find('.info').text()+'" />');
            });

            $("#uploader").on('click','.del_file',function(){
                $(this).parent().remove();
            });

            uploader.on( 'uploadError', function( file ) {
                $( '#'+file.id ).find('p.state').text('上传出错');
            });

            uploader.on( 'uploadComplete', function( file ) {
                $( '#'+file.id ).find('.progress').fadeOut();
            });



            function del_image(num){
                $('#image'+num).css('background-image','');
                $('#image_'+num).val('');
            }
            $(function(){
                $(".table1").on("change",".award",function(){
                    if($(this).next().length){ return;}
                    var copy = $(this).clone();
                    copy.find("option").removeAttr("selected").eq(0).text("-请选择-");
                    $(this).parent().append(copy);
                });
            $(".award").find("option").removeAttr("selected").eq(0).text("-请选择-");
            <foreach name="awards" item="jx" >
                var copy = $(".award").eq(0).clone();
                copy.removeAttr("selected").find("[value={$jx}]").attr("selected","selected")
                $(".award").parent().prepend(copy);
            </foreach>
                /*var  content ;
                KindEditor.ready(function(K) {
                    content = K.create('#content',{
                        allowFileManager : true,
                        uploadJson:'--PUBLIC--/kindeditor/php/upload_json.php?dirname=product'
                    });
                });*/

                KindEditor.ready(function(K) {
                    K.create();
                    var editor = K.editor({
                        allowFileManager : true,
                        uploadJson:'--PUBLIC--/kindeditor/php/upload_json.php?dirname=product'
                        //sdl:false
                    });
                    K('#uparea1').click(function() {
                        editor.loadPlugin('image', function() {
                            editor.plugin.imageDialog({
                                imageUrl : K('#image_1').val(),
                                clickFn : function(url, title, width, height, border, align) {
                                    $('#image1').css('background-image','url('+url+')').css('background-size','220px 160px');
                                    K('#image_1').val(url);
                                   // K('#getImgUrl').val(url);
                                    editor.hideDialog();
                                }
                            });
                        });
                    });

                    K('#uparea2').click(function() {
                        editor.loadPlugin('image', function() {
                            editor.plugin.imageDialog({
                                imageUrl : K('#image_2').val(),
                                clickFn : function(url, title, width, height, border, align) {
                                    $('#image2').css('background-image','url('+url+')').css('background-size','220px 160px');
                                    K('#image_2').val(url);
                                    // K('#getImgUrl').val(url);
                                    editor.hideDialog();
                                }
                            });
                        });
                    });

                    K('#uparea3').click(function() {
                        editor.loadPlugin('image', function() {
                            editor.plugin.imageDialog({
                                imageUrl : K('#image_3').val(),
                                clickFn : function(url, title, width, height, border, align) {
                                    $('#image3').css('background-image','url('+url+')').css('background-size','220px 160px');
                                    K('#image_3').val(url);
                                    // K('#getImgUrl').val(url);
                                    editor.hideDialog();
                                }
                            });
                        });
                    });
                    K('#uparea4').click(function() {
                        editor.loadPlugin('image', function() {
                            editor.plugin.imageDialog({
                                imageUrl : K('#image_4').val(),
                                clickFn : function(url, title, width, height, border, align) {
                                    $('#image4').css('background-image','url('+url+')').css('background-size','220px 160px');
                                    K('#image_4').val(url);
                                    // K('#getImgUrl').val(url);
                                    editor.hideDialog();
                                }
                            });
                        });
                    });
                    K('#uparea5').click(function() {
                        editor.loadPlugin('image', function() {
                            editor.plugin.imageDialog({
                                imageUrl : K('#image_5').val(),
                                clickFn : function(url, title, width, height, border, align) {
                                    $('#image5').css('background-image','url('+url+')').css('background-size','220px 160px');
                                    K('#image_5').val(url);
                                    // K('#getImgUrl').val(url);
                                    editor.hideDialog();
                                }
                            });
                        });
                    });
                    K('#uparea6').click(function() {
                        editor.loadPlugin('image', function() {
                            editor.plugin.imageDialog({
                                imageUrl : K('#image_6').val(),
                                clickFn : function(url, title, width, height, border, align) {
                                    $('#image6').css('background-image','url('+url+')').css('background-size','220px 160px');
                                    K('#image_6').val(url);
                                    // K('#getImgUrl').val(url);
                                    editor.hideDialog();
                                }
                            });
                        });
                    });
                    K('#uparea7').click(function() {
                        editor.loadPlugin('image', function() {
                            editor.plugin.imageDialog({
                                imageUrl : K('#image_7').val(),
                                clickFn : function(url, title, width, height, border, align) {
                                    $('#image7').css('background-image','url('+url+')').css('background-size','220px 160px');
                                    K('#image_7').val(url);
                                    // K('#getImgUrl').val(url);
                                    editor.hideDialog();
                                }
                            });
                        });
                    });
                    K('#uparea8').click(function() {
                        editor.loadPlugin('image', function() {
                            editor.plugin.imageDialog({
                                imageUrl : K('#image_8').val(),
                                clickFn : function(url, title, width, height, border, align) {
                                    $('#image8').css('background-image','url('+url+')').css('background-size','220px 160px');
                                    K('#image_8').val(url);
                                    // K('#getImgUrl').val(url);
                                    editor.hideDialog();
                                }
                            });
                        });
                    });
                    K('#uparea9').click(function() {
                        editor.loadPlugin('image', function() {
                            editor.plugin.imageDialog({
                                imageUrl : K('#image_9').val(),
                                clickFn : function(url, title, width, height, border, align) {
                                    $('#image9').css('background-image','url('+url+')').css('background-size','220px 160px');
                                    K('#image_9').val(url);
                                    // K('#getImgUrl').val(url);
                                    editor.hideDialog();
                                }
                            });
                        });
                    });
                    K('#uparea10').click(function() {
                        editor.loadPlugin('image', function() {
                            editor.plugin.imageDialog({
                                imageUrl : K('#image_10').val(),
                                clickFn : function(url, title, width, height, border, align) {
                                    $('#image10').css('background-image','url('+url+')').css('background-size','220px 160px');
                                    K('#image_10').val(url);
                                    // K('#getImgUrl').val(url);
                                    editor.hideDialog();
                                }
                            });
                        });
                    });


                });
                $("#checkNewsTitle").click(function(){
                    if($('#title').val()==''){
                        popup.error('标题不能为空！');
                        return false;
                    }
                    $.getJSON("__URL__/checkProductTitle", { title:$("#title").val(),id:"{$info.id}"}, function(json){
                        $("#checkNewsTitle").css("color",json.status==1?"#0f0":"#f00").html(json.info);
                    });
                });
                $(".submit").click(function(){
                    if($('#title').val()==''){
                        popup.error('标题不能为空！');
                        return false;
                    }
                    // content.sync();
                    commonAjaxSubmit("{$action_url}");
                    return false;
                });
            });
        </script>
    </body>
</html>
